
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Rectangle.h>
#include <iostream>

USING_MOCKCPP_NS
USING_TESTNGPP_NS


FIXTURE(RectLengthCheck)
{
    TEST(should get 0 if length = 0 when calculating area)
    {
         Rectangle rect(0, 20.123456);
         ASSERT_EQ(0, rect.calcArea());
    }

    TEST(should get 0 if length < 0 (length = -10.536) when calculating area)
    {
         Rectangle rect(-10.536, 20.123456);
         ASSERT_EQ(0, rect.calcArea());
    }

    TEST(should get 0 if length > 100 (length = 100.536) when calculating area)
    {
         Rectangle rect(100.536, 20.123456);
         ASSERT_EQ(0, rect.calcArea());
    }


    TEST(should be able to calculate area when length is 100: 100 * 20.123456 = 2012)
    {
         Rectangle rect(100, 20.123456);
         ASSERT_EQ(2012, rect.calcArea());
    }
    
    TEST(should not change original area when set invalid length 0: 10.235 * 20.823456 = 212.99)
    {
         Rectangle rect(10.235, 20.823456);
         rect.setLength(0); 
         ASSERT_EQ(212.99, rect.calcArea());
    }

    TEST(should not change original area when set invalid length 105: 10.235 * 20.823456 = 212.99)
    {
         Rectangle rect(10.235, 20.823456);
         rect.setLength(105);
         ASSERT_EQ(212.99, rect.calcArea());
    }
};


FIXTURE(RectWidthCheck)
{        
    TEST(should get 0 if width = 0 when calculating perimeter)
    {
         Rectangle rect(10.235, 0);
         ASSERT_EQ(0, rect.calcPerimeter());
    }

    TEST(should get 0 if width < 0 (width = -20.123456) when calculating perimeter)
    {
         Rectangle rect(10.235, -20.123456);
         ASSERT_EQ(0, rect.calcPerimeter());
    }

    TEST(should get 0 if width > 75 (width = 78.536) when calculating perimeter)
    {
         Rectangle rect(10.536, 78.536);
         ASSERT_EQ(0, rect.calcPerimeter());
    }


    TEST(should get 0 if width = 75 when calculating area)
    {
         Rectangle rect(100, 75.0012);
         ASSERT_EQ(0, rect.calcArea());
    }

    TEST(should not change original perimeter when set invalid width 0: 2*(10.235 + 20.123456) = 60.7)
    {
         Rectangle rect(10.235, 20.123456);
         rect.setWidth(0);
         ASSERT_EQ(60.7, rect.calcPerimeter());
    }

    TEST(should not change original perimeter when set invalid width 75.687: 2*(10.235 + 20.123456) = 60.7)
    {
         Rectangle rect(10.235, 20.123456);
         rect.setWidth(75.687);
         ASSERT_EQ(60.7, rect.calcPerimeter());
    }


};

FIXTURE(RectCalc)
{
    TEST(should be able to calculate area(reserve 2 digit for para, round for result): 10.147 * 20.823456 = 211.11)
    {
         Rectangle rect(10.147, 20.823456);
         ASSERT_EQ(211.11, rect.calcArea());
    }
    
    TEST(should be able to set length&width to 51.345&33.4512 before culating area: 51.345 * 33.412 = 1715.27)
    {
         Rectangle rect(10.147, 20.823456);
         rect.setLength(51.345);
         rect.setWidth(33.412);
         ASSERT_EQ(1715.27, rect.calcArea());
    }


    TEST(should be able to calculate perimeter(reserve 2 digit for para, round for result): 2 * (10.147 + 20.823456) = 61.92)
    {
         Rectangle rect(10.147, 20.823456);
         ASSERT_EQ(61.92, rect.calcPerimeter());
    }

    TEST(should be able to set length&width to 51.345&33.4512 before culating perimeter: 2 * (51.345 + 33.4512) = 169.58)
    {
         Rectangle rect(10.147, 20.823456);
         rect.setLength(51.345);
         rect.setWidth(33.4512);
         ASSERT_EQ(169.58, rect.calcPerimeter());
    }


};

/*
FIXTURE(Square)
{
    TEST(should get 0 if side = 0 when calculating area)
    {
         Square square(0);
         ASSERT_EQ(0, square.calcArea());
    }
    
    TEST(should get 0 if side < 0 when calculating perimeter)
    {
         Square square(-10.588);
         ASSERT_EQ(0, square.calcPerimeter());
    }

    TEST(should get 0 if side > 75  when calculating area)
    {
         Square square(75.235);
         ASSERT_EQ(0, square.calcArea());
    }


    TEST(should be able to calculate area(reserve 2 digit for para, round for result): 10.147 * 10.147 = 102.82)
    {
         Square square(10.147);
         ASSERT_EQ(102.82, square.calcArea());
    }

    TEST(should be able to calculate perimeter(reserve 2 digit for para, round for result): 4 * 10.147 = 40.56)
    {
         Square square(10.147);
         ASSERT_EQ(40.56, square.calcPerimeter());
    }
   
    TEST(should be able to set side to 51.345 before culating area: 51.345 * 51.345 = 2635.80)
    {
         Square square(10.147);
         square.setSide(51.345);
         ASSERT_EQ(2635.80, square.calcArea());
    }

    TEST(should get original area  when set invalid side to 78 before culating area)
    {
         Square square(10.147);
         square.setSide(78);
         ASSERT_EQ(102.82, square.calcArea());
    }

};

*/

